package view;

import domain.ATM;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.layout.Pane;

import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;

public class BalanceViewController implements ControlledStage, Initializable {

    private StageController myController;
    private ATM atm;

    @FXML
    private Pane balancePane;
    @FXML
    private TextField balanceField;
    @FXML
    private Button confirm;


    public void setStageController(StageController stageController) {
        this.myController = stageController;
        atm = myController.getAtm();
        balanceField.setText(atm.getCurAccount().getBalance().toString());
    }

    public void initialize(URL location, ResourceBundle resources) {

    }

    public void goToMain(){
        myController.setStage(MainApp.mainViewID);
    }


    @FXML
    private void confirmAction(ActionEvent event) throws IOException {
        atm = myController.getAtm();
        System.out.println("You clicked the Button " + confirm.getId());
        System.out.println("The balanceField is " + balanceField.getText());

        myController.setStage(MainApp.mainViewID,MainApp.balanceViewID);
    }

}
